<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>04width和height方法</title>
</head>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: #965230;
            padding: 20px;
            border: 10px solid #ccc;
            margin: 10px;
        }
    </style>
<body>
    <div></div>

    <script src="../jquery-3.2.1.js"></script>
    <script>
    
        $(function(){
            // 获取div高度
            // console.log($("div").css("width"));
            console.log($("div").innerWidth())  // 获取padding + width
            console.log($("div").outerWidth())  // 获取padding + width + border
            console.log($("div").outerWidth(true))  // 获取padding + width + border + margin
            // console.log($("div").width());  //  只获取width值
            $("div").width(500);        // 设置高度

            // 获取页面可视区的宽度高度
            $(window).resize(function(){
                console.log($(window).width());
                console.log($(window).height());
            })
        });
        
    </script>
</body>
</html>